package com.byb.server.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * 费录表
 */
@ApiModel(description = "费录表")
@Entity
@Table(name = "rate")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "rate")
public class Rate implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 年龄
     */
    @ApiModelProperty(value = "年龄")
    @Column(name = "age")
    private Integer age;

    /**
     * 价格
     */
    @ApiModelProperty(value = "价格")
    @Column(name = "price")
    private Float price;

    /**
     * 缴费年限
     */
    @ApiModelProperty(value = "缴费年限")
    @Column(name = "premium_payment_period")
    private Integer premiumPaymentPeriod;

    @ManyToOne
    private Product product;

    @ManyToOne
    private Sex sex;

    // jhipster-needle-entity-add-field - Jhipster will add fields here, do not remove
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getAge() {
        return age;
    }

    public Rate age(Integer age) {
        this.age = age;
        return this;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Float getPrice() {
        return price;
    }

    public Rate price(Float price) {
        this.price = price;
        return this;
    }

    public void setPrice(Float price) {
        this.price = price;
    }

    public Integer getPremiumPaymentPeriod() {
        return premiumPaymentPeriod;
    }

    public Rate premiumPaymentPeriod(Integer premiumPaymentPeriod) {
        this.premiumPaymentPeriod = premiumPaymentPeriod;
        return this;
    }

    public void setPremiumPaymentPeriod(Integer premiumPaymentPeriod) {
        this.premiumPaymentPeriod = premiumPaymentPeriod;
    }

    public Product getProduct() {
        return product;
    }

    public Rate product(Product product) {
        this.product = product;
        return this;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public Sex getSex() {
        return sex;
    }

    public Rate sex(Sex sex) {
        this.sex = sex;
        return this;
    }

    public void setSex(Sex sex) {
        this.sex = sex;
    }
    // jhipster-needle-entity-add-getters-setters - Jhipster will add getters and setters here, do not remove

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Rate rate = (Rate) o;
        if (rate.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), rate.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getId());
    }

    @Override
    public String toString() {
        return "Rate{" +
            "id=" + getId() +
            ", age='" + getAge() + "'" +
            ", price='" + getPrice() + "'" +
            ", premiumPaymentPeriod='" + getPremiumPaymentPeriod() + "'" +
            "}";
    }
}
